<!DOCTYPE html
	PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<title>脸云 - 签到系统</title>
		<link rel="stylesheet" href="../css/style.default.css" type="text/css" />
		<script type="text/javascript" src="../js/plugins/jquery-1.7.min.js"></script>
		<script type="text/javascript" src="../js/plugins/jquery-ui-1.8.16.custom.min.js"></script>
		<script type="text/javascript" src="../js/plugins/jquery.cookie.js"></script>
		<script type="text/javascript" src="../js/plugins/jquery.uniform.min.js"></script>
		<script type="text/javascript" src="../js/plugins/jquery.validate.min.js"></script>
		<script type="text/javascript" src="../js/plugins/jquery.tagsinput.min.js"></script>
		<script type="text/javascript" src="../js/plugins/charCount.js"></script>
		<script type="text/javascript" src="../js/plugins/ui.spinner.min.js"></script>
		<script type="text/javascript" src="../js/plugins/chosen.jquery.min.js"></script>
		<script type="text/javascript" src="../js/custom/general.js"></script>
		<script type="text/javascript" src="../js/custom/forms.js"></script>
		<script src="../js/baseServerLink.js" type="text/javascript" charset="utf-8"></script>
		<script src="../js/qrcode.min.js" type="text/javascript" charset="utf-8"></script>

		<!--[if IE 9]>
    <link rel="stylesheet" media="screen" href="css/style.ie9.css"/>
<![endif]-->
		<!--[if IE 8]>
    <link rel="stylesheet" media="screen" href="css/style.ie8.css"/>
<![endif]-->
		<!--[if lt IE 9]>
	<script src="http://css3-mediaqueries-js.googlecode.com/svn/trunk/css3-mediaqueries.js"></script>
<![endif]-->

		<!-- 圆角绿色小按钮！ -->
		<style type="text/css">
			.my_green_button {
				background-color: #95f04b;
				border: 0;
				border-radius: 20px;
				-moz-border-radius: 20px;
				/* 老的 Firefox */
				font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;
				font-weight: bold;
				color: #5c8f30;
				border: 1px solid #6eac3a;
			}
		</style>

		<script type="text/javascript">
			// 将页面切换至操作面板
			function toPage2(id) {
				jQuery('#page2').click();
				jQuery('#page2iframe').attr('src', 'jumpToServlet?mode=cilab&id=' + id);
			}
			
			function toPage2src(src) {
				jQuery('#page2').click();
				jQuery('#page2iframe').attr('src', src);
			}
			

			function addLine(id, tbline1, tbline2, tbline3, tbline4 ) {
				/*
				<tr>
					<td> 李四 </td>
					<td>789@qq.com</td>
					<td>8</td>
					<td>9</td>
					<td><a href="#" class="btn btn2 btn_archive"><span>操作</span></a></td>
				</tr>
				*/
				//展示信息的行
				$tr = jQuery("<tr class=\"vartr\"></tr>");
				$tr.append(jQuery("<td>" + tbline1 + "</td>"));
				$tr.append(jQuery("<td>" + tbline2 + "</td>"));
				
				//正常
				if(tbline3 == 1){
					tbline3 = "<b style='color:green'>正常</b>";
					var isNormal = 1;
				}
				
				//禁用
				else if(tbline3 == 0){
					tbline3 = "<b style='color:red'>停用</b>";
					var isNormal = 0;
				}
				
				//未知状态
				else{
					tbline3 = "<b>未知状态："+tbline3+"</b>";
					var isNormal = -1;
				}
				$tr.append(jQuery("<td>" + tbline3 + "</td>"));
				
				
				$tr.append(jQuery("<td>" + tbline4 + "</td>"));

				$opi = jQuery('<a id="aid_' + id + '" class="btn btn2 btn_archive"  style="width: 75px;"><span>操作</span></a>');
				$opi.click(function() {
					eval("jQuery('#userid_'+id).show();");
				})
				$tr.append(jQuery("<td></td>").append($opi));

				//详细信息的行
				$frametr = jQuery("<tr class=\"vartr\"></tr>");
				//设置此行id,用于隐藏和显示
				$frametr.attr("id", "userid_" + id);
				$frametr.hide();
				$closeButton = jQuery("<button'>关闭</buttton>");
				$closeButton.click(function() {
					eval("jQuery('#userid_'+id).hide();");
				})
				//加入关闭按钮
				$frametr.append(jQuery("<td></td>").append($closeButton));

				//拓展界面的内容
				//居中div
				$iframe = jQuery('<div style="width:100%; text-align: center;"></div>');
				//修改实验室信息按钮
				$btn_jmp = jQuery('<br/><button  class="stdbtn btn_orange">修改此实验室信息</button>');
				$btn_jmp.click(function() {
					toPage2("" + id);
				});
				$iframe.append($btn_jmp);
				
				function getPathOfPage(){
					/////////////JS获取项目名//////////////
					//获取当前网址，如：
					var curWwwPath=window.document.location.href;
					
					//获取主机地址之后的目录如：/Tmall/index.jsp
					var pathName=window.document.location.pathname;
					var pos=curWwwPath.indexOf(pathName);
					
					//获取主机地址，如：//localhost:8080
					var localhostPaht=curWwwPath.substring(0,pos);
					
					//获取带"/"的项目名，如：/Tmall
					var projectName=pathName.substring(0,pathName.substr(1).indexOf('/')+1); 
					
					// "http://localhost:8080/QM/loginci.html?d=1638322099989" -> projectName: "/QM"
					
					/////////////////////////////////////
					return localhostPaht + projectName;
				}
				
				
				
				
				//正常
				if(isNormal == 1){
					//var linkhref = "http://"+window.location.host+"/QM/checkin/"+'ciin.jsp?labid='+id+'&labname='+tbline...
					var linkhref = getPathOfPage() + "/checkin/"+'ciin.jsp?labid='+id+'&labname='+tbline2+'';
					$btn_jmptoci = jQuery('<span>&nbsp; &nbsp; &nbsp; </span> <a target="_blank" href="ciin.jsp?labid='+id+'&labname='+tbline2+'" class="btn btn_link"><span>此实验室签到链接</span></a>');
					$iframe.append($btn_jmptoci);
					
					$divCenter = jQuery("<div style='margin: 0 auto;text-align: center; width: 110px;'></div>");
					
					var dqr = document.createElement('div');
					dqr.setAttribute('id', 'qr_'+id);
					// 二维码！
					new QRCode(dqr, {
						text:linkhref,
						width:100,
						height:100,
					});
					$divCenter.append("<br/>");
					$divCenter.append(dqr);//二维码
					
					//$divCenter.append("");
					$iframe.append($divCenter);
					$iframe.append("<span>保存此二维码，扫描打开签到页面，签到无需登录</span><br/><br/>");
					//修改实验室签到内容的按钮
					$btn_jmpcitext = jQuery('<button  class="stdbtn btn_yellow"><span style="color: black;font-size: larger;"></span>修改此实验室签到文本</button>');
					$btn_jmpcitext.click(function() {
						toPage2src("jumpToServlet?mode=citext&id="+id);
					});
					$iframe.append($btn_jmpcitext);
					$iframe.append("<span>&nbsp; &nbsp; &nbsp; </span>");
					//安全检查
					$btn_jmpcilabsafe = jQuery('<button  class="stdbtn btn_red"><span style="color: white;font-size: larger;font-weight: bolder;">(√)&nbsp;</span>此实验室的安全检查单</button>');
					$btn_jmpcilabsafe.click(function() {
						toPage2src("jumpToServlet?mode=cilabrecord&id="+id);
					});
					$iframe.append($btn_jmpcilabsafe);
					//eval("new QRCode(document.getElementById('qr_"+id+"'), {text:"++linkhref", width: 128, height: 128,})");
				}
				//加入iframe
				$frametr.append(jQuery("<td colspan='4'></td>").append($iframe));

				jQuery("#my_tbody").append($tr);
				jQuery("#my_tbody").append($frametr);
				
			}


			function load_all_users() {
				//////////////////////////////////////debug//////////////////////////////////

				//////////////////////////////////////debug//////////////////////////////////
				$vartr = jQuery(".vartr");
				for (var i = 0; i < $vartr.length; i++) {
					$vartr.remove();
				}
				console.log("开始查询");
				jQuery.ajax({
					url: '../CilabServlet',
					data: {
						'mode': 41 
					},

					success: function(message) {
						console.log(message);
						// alert(message);
						if (message[0] != '[') {
							window.location.href = "../index.jsp";
						} else {
							eval("message=" + message);
							
							if(message.length == 0){
								jQuery("#ooops_message").show();
								return;
							}
							else{
								jQuery("#ooops_message").hide();
							}
							jQuery("#id_user_num").text("共查询到 " + message.length + " 条记录");
							var d = new Date();
							jQuery('#reload_date').text(""+d);
							
							for (line in message) {
								my_line = message[line];
								addLine(
									my_line['id'],
									my_line['location'],
									my_line['name'],
									my_line['available'],
									my_line['memo']
									
								);
							}
						}
					},
					error: function(message) {
						console.log(message)
					}
				})
			}

			jQuery(function() {
				load_all_users();
			})
		</script>

	</head>

	<body class="withvernav">

		<div class="bodywrapper">
			<iframe style="background-color: #485b79;" src="cilabadmin_top.html" width="100%" height="160px"></iframe>
			<!--header-->

			<div class="vernav2 iconmenu">
				<ul>
					<li><a href="#formsub" class="editor">帮助手册</a>
						<!-- <span class="arrow"></span>
						<ul id="formsub">
							<li class="current"><a href="forms.html">系统概览</a></li>
						</ul> -->
					</li>

				</ul>
				<a class="togglemenu"> </a>
				<br /><br />
			</div>
			<!--leftmenu-->

			<div class="centercontent">

				<div class="pageheader">
					<h1 class="pagetitle">实验室信息管理</h1>
					<span class="pagedesc">Lab Information Management</span>

					<ul class="hornav">
						<li class="current"><a id="tag_1" href="#preview_system">实验室列表</a></li>
						<script type="text/javascript">
							jQuery(function(){
								jQuery("#tag_1").click(function(){
									load_all_users();
								});
							});
						</script>
						<li><a id="page2" href="#preview_dev">操作面板</a></li>

					</ul>

				</div>

				<!--pageheader-->
				<div id="contentwrapper" class="contentwrapper">
					<!-- #################### 页面1开始 ####################-->
					<div id="preview_system" class="subcontent">
						<a href="#" class="btn btn_blue btn_flag"><span id="id_user_num">共查询到 条记录</span></a>
						<!-- <button id="add_newcilab" type="button" class="my_green_button">
							<span style="line-height: 30px;">
								<span style="color: white; font-size: larger;">
									(+)
								</span>
								新增新的实验室
							</span>
						</button> -->
						
						<script>
						jQuery(function(){
							jQuery("#add_newcilab").click(function(){
								toPage2src("cilabregister.html");
							})
						});
						
						</script>
						
						<a href="javascript:load_all_users();" class="btn btn2 btn_search"><span>重新查询数据</span></a>
						<br />
						<br />
						（此表数据最后一次刷新于：
						<span id="reload_date">
							-
						</span>
						）
						
						<br />
						<table cellpadding="0" cellspacing="0" border="0" class="stdtable" style="text-align: center;">
							<colgroup>
								<col class="con0" />
								<col class="con1" />
								<col class="con0" />
								<col class="con1" />
								<col class="con0" />
							</colgroup>
							<thead>
								<tr>
									<th class="head0" style="text-align: center;">实验室地址</th>
									<th class="head1" style="text-align: center;">实验室名</th>
									<th class="head1" style="text-align: center;">状态</th>
									<th class="head1" style="text-align: center;">备注</th>
									<th class="head1" style="text-align: center;">操作</th>
								</tr>
							</thead>
							<tbody id="my_tbody">
								<!-- <tr class="vartr">
									<td style="text-align: center;"> 张三 </td>
									<td>123456@qq.com</td>
									<td>2</td>
									<td>8</td>
									<td><a href="#" class="btn btn2 btn_archive" ><span>操作</span></a></td>
								</tr>

								<tr class="vartr">
									<td style="text-align: center;"> 李四 </td>
									<td>789@qq.com</td>
									<td>8</td>
									<td>9</td>
									<td><a href="#" class="btn btn2 btn_archive"><span>操作</span></a></td>
								</tr> -->
							</tbody>
						</table>
					</div>
					<center id="ooops_message"><span style="color: blue" >ooops, 您虽然是实验室管理员，但似乎并没有实验室可以管理。</span><br>如果此情况持续出现，请联系系统管理人员。</center>
					<!-- #################### 页面2结束 ####################-->
					<!-- #################### 帮助手册 ####################-->
					<div id="preview_dev" class="subcontent" style="display: none">

						<div class="contenttitle2">
							操作面板将显示选择的功能。请在列表选择功能，页面将自动跳转到此处。
						</div>

						<iframe id="page2iframe" src="" width="100%" height="1920"></iframe>
					</div>
					<!-- #################### 帮助手册结束 ####################-->
				</div>
			</div>
			<!---->
		</div>
		<!--bodywrapper-->

	</body>
</html>
